<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品分类</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <!-- 添加按钮 -->
      <el-row>
        <el-col>
          <el-button type="primary">添加分类</el-button>
        </el-col>
      </el-row>
      <!-- 数据表格区域 -->
      <!-- <tree-table :data="catelist" :columns="columns"> </tree-table> -->

      <el-table
        :data="catelist"
        style="width: 100%; margin-bottom: 20px"
        :row-key="catelist.cat_id"
        border
        :tree-props="{
          children: 'children',
        }"
      >
        <el-table-column prop="cat_name" label="分类名称" width="180">
        </el-table-column>
        <el-table-column prop="cat_deleted" label="是否有效" width="180">
          <template v-slot="scope">
            <i
              class="el-icon-success"
              v-if="scope.row.cat_delete == false"
              style="color: green"
            ></i>
            <i class="el-icon-error" style="color: red" v-else></i>
          </template>
        </el-table-column>
        <el-table-column prop="address" label="排序">
          <template v-slot="scope">
            <el-tag v-if="scope.row.cat_level == 0">一级</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作">
          <template v-slot="scope">
            <el-button type="primary" size="mini">编辑按钮</el-button>
            <el-button type="danger" size="mini">删除按钮</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination background layout="prev, pager, next" :total="total">
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      catelist: [],
      queryinfo: {
        type: 3,
        pagenum: 1,
        pagesize: 5,
      },
      total: 0,
      // columns: [
      //   {
      //     label: "分类名称",
      //     prop: "cat_name",
      //   },
      // ],
    };
  },
  created() {
    this.getcatelist();
  },

  methods: {
    async getcatelist() {
      const { data: res } = await this.$http.get("categories", {
        params: this.queryinfo,
      });
      this.catelist = res.data.result;
      this.total = res.data.total;
      console.log(res.data.result);
    },
  },
};
</script>

<style></style>
